<?php 
    class Carreras_model extends CI_Model {

        private $_tabla = 'carreras';
		public $idCarrera = 0;
		public $descripcion = '';
		public $estado = true;
		
        public function getAll()
        {
            return $this->db->get($this->_tabla)->result_array();
        }
		
		public function insert()
		{
			$this->db->insert($this->_tabla, $this);
		}
		
		public function update()
		{
			$this->db->where('idCarrera', $this->idCarrera);
			$this->db->update($this->_tabla,$this);
		}
		
		public function getById($id)
		{
			$query = $this->db->query("SELECT * FROM " . $this->_tabla . " WHERE idCarrera = '" . $id . "'");

			foreach ($query->result() as $row)
			{
				return $row;
			}
		}

		    //by rube :$
    public function Buscador($patron,$tipo){
        $query = $this->db->query("SELECT * FROM ". $this->_tabla . " WHERE estado = '" . $tipo . "' AND descripcion LIKE '%" . $patron . "%'");
        return $query->result_array();
    }   

    public function getAllByEstado($tipo){
        $this->db->where('estado',$tipo);
        return $this->db->get($this->_tabla)->result_array();
    }

    public function baja_alta_Logica($id,$valor){
        $data = array('estado'=>$valor);
        $this->db->where('idCarrera',$id);
        $this->db->update($this->_tabla,$data);
    }
    // by rube :$
	}
?>